2d array - ds hackerrank solution in python